<%@ page import="com.czxy.utils.CookieUtils" %>
<%@ page import="java.net.URLDecoder" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<html>
<head>
	<meta http-equiv="Content-Language" content="zh-cn">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title></title>
	<link href="${pageContext.request.contextPath}/css/Style.css" rel="stylesheet" type="text/css">

	<script>
		<%--			点击切换验证码 方法 --%>
		function changeVcImg(element) {

			element.src="${pageContext.request.contextPath}/userServlet?method=getVcImg&time="+new Date().getTime();
		}

	</script>

</head>

<body>

<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td align="center">
			<table width="452" height="290" border="0" cellpadding="0" cellspacing="0">
				<tr>
					<td bgcolor="#FFFFFF">
						<table width="452" height="290" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td height="74">
									<img src="${pageContext.request.contextPath}/images/logintitle.gif">
								</td>
							</tr>
							<tr>
								<td align="center" valign="bottom"
									background="${pageContext.request.contextPath}/images/loginbg.gif"
									style="background-repeat: no-repeat">
									<form action="${pageContext.request.contextPath}/userServlet" method="post" target="_parent">

										<input type="hidden" name="method" value="login">

										<table border="0" align="center" cellpadding="2" cellspacing="0">
											<tr align="center">
												<td height="30" colspan="2" style="border-bottom: 1px dotted #cccccc">
													<strong style="font-size: 14px;">${msg}</strong>
												</td>
											</tr>
											<tr>
												<td height="30" nowrap>
													<font color="000F60"><strong>用户名：</strong> </font>
												</td>
												<td>


													<%
														// 把cookie中的 数据获取出来, 解码 存储到page域中, 使用EL表达式获取解码之后的数据
														Cookie usernameCK = CookieUtils.getCookie(request.getCookies(), "username");
														Cookie passwordCK = CookieUtils.getCookie(request.getCookies(), "password");
														String username = "";
														String password = "";
														if(usernameCK!=null){
															username =	URLDecoder.decode(usernameCK.getValue(),"UTF-8");
															pageContext.setAttribute("username", username);
														}
														if(passwordCK!=null){
															password =	URLDecoder.decode(passwordCK.getValue(),"UTF-8");
															pageContext.setAttribute("password", password);
														}


													%>


													<input type="text" name="loginName" class="test" value="${username}"  style="width: 160px;"/>
												</td>
											</tr>
											<tr>
												<td height="30" nowrap>
													<strong><font color="000F60">密码： </font> </strong>
												</td>
												<td>
													<input type="password" name="loginPwd"  value="${password}" class="text" style="width: 160px;"/>
												</td>
											</tr>
											<tr>
												<td height="30" nowrap>
													<strong><font color="000F60">验证码： </font> </strong>
												</td>
												<td>
													<input type="text" name="vcText" class="text"
														   style="width: 60px;"/>
													<img alt=""
														 src="${pageContext.request.contextPath}/userServlet?method=getVcImg"
														 onclick="changeVcImg(this)"
													>
												</td>
											</tr>
											<tr>
												<td height="30" nowrap>
													<strong><font color="000F60">  </font> </strong>
												</td>
												<td>
													<input type="checkbox" name="autoLogin" ${not empty cookie.autoInfo ? "checked":""} > 自动登录
													<%--															checked=" ${cookie.RMsta.value eq 1} ?'true':'false' "--%>
													<c:if test="${cookie.RMsta.value eq 1}">
														<input type="checkbox" name="rememberMe" checked > 记住我
													</c:if>
													<c:if test="${cookie.RMsta.value ne 1}">
														<input type="checkbox" name="rememberMe"   > 记住我
													</c:if>

												</td>

											</tr>
											<tr>
												<td height="30">
												</td>
												<td>
													<input type="submit"  value="登录" class="buttoninput" />
													<input type="reset"  value="取消" class="buttoninput" />
												</td>
											</tr>
										</table>
									</form>
									<table width="100%" border="0" cellspacing="0" cellpadding="0">
										<tr>
											<td height="30" align="center">
											</td>
										</tr>
										<tr>
											<td height="23" align="center"></td>
										</tr>
									</table>
								</td>
							</tr>

						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
</body>
</html>